package com.qumitech.visualnovel.controller.rest;

import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.*;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.controller.vo.risk.UserAlarmAddDTO;
import com.qumitech.visualnovel.service.risk.RiskUserAlarmService;

@RestController
@RequestMapping("/api/risk")
public class RiskUserAlarm {
    @Autowired
    private RiskUserAlarmService riskUserAlarmService;

    @GetMapping(value = "/user/alarm/query")
    public BaseRsp queryRiskUserAlarmConf(
        @RequestParam(value = "alarmType", required = false) String alarmType,
        @RequestParam(value = "alarmValue", required = false) String alarmValue,
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime,
        @RequestParam(value = "offset", required = false) String offset,
        @RequestParam(value = "limit", required = false) String limit) {
        return riskUserAlarmService.queryRiskUserAlarmConf(alarmType, alarmValue, startTime, endTime, offset, limit);
    }

    @PostMapping(value = "/user/alarm/add")
    public BaseRsp addRiskUserAlarmConf(@RequestBody UserAlarmAddDTO addDTO) {
        return riskUserAlarmService.addRiskUserAlarmConf(addDTO);
    }

    @DeleteMapping(value = "/user/alarm/del/{autoid}")
    public BaseRsp delRiskUserAlarmConf(@PathVariable(name = "autoid") String autoid) {
        return riskUserAlarmService.delRiskUserAlarmConf(autoid);
    }

    @GetMapping(value = "/user/chat/query")
    public BaseRsp queryRiskUserChats(
        @RequestParam(value = "content", required = false) String content,
        @RequestParam(value = "sender", required = false) String sender,
        @RequestParam(value = "receiver", required = false) String receiver,
        @RequestParam(value = "status", required = false) String status,
        @RequestParam(value = "startTime", required = false) String startTime,
        @RequestParam(value = "endTime", required = false) String endTime,
        @RequestParam(value = "offset", required = true) String offset,
        @RequestParam(value = "limit", required = true) String limit) {
        return riskUserAlarmService.queryRiskUserChats(content, sender, receiver, status, startTime, endTime, offset, limit);
    }

    @GetMapping(value = "/user/chat/alarm")
    public BaseRsp queryRiskUserChatsAlarm() {
        return riskUserAlarmService.queryRiskUserChatsAlarm();
    }
}
